<template>
    <div>
        <!-- 新闻列表 -->
        <ul class="mui-table-view">
            <li class="mui-table-view-cell mui-media" v-for="(item,index) in newsList" :key="index">
                <router-link :to="'/home/newsInfo/'+item.id">
                    <img class="mui-media-object mui-pull-left" :src="item.img_url">
                    <div class="mui-media-body">
                        <h1 class="mui-ellipsis">{{item.title}}</h1>
                        <p>
                            <span class="mui-ellipsis">发表时间：{{item.add_time | fordate}}</span>
                            <span class="mui-ellipsis">点击次数:{{item.click}}次</span>
                        </p>
                    </div>
                </router-link>
            </li>
		</ul>
    </div>
</template>

<script>
import { Toast } from 'mint-ui'
export default {
    data(){
        return{
            newsList:[]
        }
    },
    created(){
        this.getNewsList()
    },
    methods:{
        getNewsList(){
            this.$http.get('api/getnewslist').then(result=>{
                // console.log(result)
                if(result.status === 200 && result.data.status === 0){
                    this.newsList = result.data.message
                }else{
                    Toast('新闻列表请求失败')
                }

            })
        }
    }
};
</script>

<style lang = 'less' scoped>
    .mui-table-view{
        h1{
            font-size: 12px;
        }
        p{
            color:#0069ff;
            display: flex;
            justify-content: space-between;
            span{
                font-size: 12px;
            }
        }
    }
</style>